package de.cube3d.blitwit.test.cases 
{
	import de.cube3d.blitwit.render.BlitSpriteScene;
	import de.cube3d.blitwit.test.Test;
	import de.cube3d.blitwit.test.Util;
	import flash.geom.Point;
	import flash.display.Graphics;
	import flash.utils.getTimer;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.display.BitmapData;
	import de.cube3d.blitwit.render.*;
	import de.cube3d.blitwit.space.*;
	/**
	 * ...
	 * @author Eike Decker
	 */
	public class TestScaling extends Test
	{
		
		override protected function init():void {
			scene.scaling = .5
			var bgspace:GridSpace = new GridSpace( -5000, -5000, 10000, 10000,200,200);
			var fgspace:BTSpace = new BTSpace ( -5000, -5000, 10000, 10000);
			bgspace.add(new BlitSpriteTexture(Util.getBitmap("tile_ground_grass"), -50000, -50000, 100000, 100000).setSortIndex(-100000));
			var sprites:Vector.<BitmapData> = new Vector.<BitmapData>();
			for (var i:int = 0; i < 10; i += 1) sprites.push(Util.getBitmap("fountain_" + i));
			
			fgspace.add(new BlitSpriteBitmap(Util.getBitmap("house_1_1"), 100, 100).setSortIndex(100));
			fgspace.add(new AnimatedBitmap(sprites, 94.25, 120.55, 20).setSortIndex(120));
			for (i = 0; i <500; i += 1) {
				var x:Number = Util.random() * 1500;
				var y:Number = Util.random() * 1500;
				if (Util.random() > .5) fgspace.add(new BlitSpriteBitmap(Util.getBitmap("house_1_"+(int(Util.random()*4+1))), x, y).setSortIndex(y));
				else fgspace.add(new AnimatedBitmap(sprites, x, y, Util.random()*15+15).setSortIndex(y));
			}
			/*fgspace.add(new AnimatedBitmap(sprites, 94.25, 70.55, 20).setSortIndex(70));
			
			bgspace.add(new BlitSpriteBitmap(Util.getBitmap("house_1_1"), 100, 300).setSortIndex(300));
			bgspace.add(new AnimatedBitmap(sprites, 94.25, 320.55, 20).setSortIndex(320));
			bgspace.add(new AnimatedBitmap(sprites, 94.25, 270.55, 20).setSortIndex(270));*/
			
			scene.append(bgspace);
			scene.append(fgspace);
			
		}
		
		override public function renderTick(t:Number):void {
			scene.scaling = Math.sin(t / 1000) * .5 + 1;
		}
		
	}

}